package com.jcroke.PC32.transformer;

import java.util.Hashtable;
import java.util.LinkedHashMap;

import com.jcroke.PC32.basetransform.DefaultTransformer;
import com.jcroke.PC32.datum.Datum;
import com.jcroke.PC32.datum.dString;

/**
 * 
 * @author jcroke
 *
 */
public class Splitter extends DefaultTransformer {

	// Input tags
	private final String INPUT = "input1";
	private final String DELIM = "input2";
	private final String OUTPUT_1 = "split_first_half_out";
	private final String OUTPUT_2 = "split_second_half_out";

	public void execute() {

		LinkedHashMap<String, Datum> inputs = getInput();

		String input = inputs.get(INPUT).toString();
		String delim = inputs.get(DELIM).toString();

		String[] sOut = input.split(delim);

		dString output_1 = new dString(sOut[0]);
		dString output_2 = new dString(sOut[1]);

		Hashtable<String, Datum> outputs = new Hashtable<String, Datum>();

		outputs.put(OUTPUT_1, output_1);
		outputs.put(OUTPUT_2, output_2);
		emit(outputs);
	}

}
